# -*- coding: utf-8 -*-
# _author: zb
# date: 19-4-22 下午3:47

from haystack import indexes
from .models import QuesModel


class QuesIndex(indexes.SearchIndex, indexes.Indexable):
    """Ques数据索引模型类"""

    text = indexes.CharField(document=True, use_template=True)
    title = indexes.CharField(model_attr='title')
    id = indexes.IntegerField(model_attr='id')
    label = indexes.CharField(model_attr='label')
    content = indexes.CharField(model_attr='content')

    def get_model(self):
        """返回建立索引的模型类"""
        return QuesModel

    # 对相关的数据进行筛选
    # def index_queryset(self, using=None):
    #     """返回要建立索引的数据查询集"""
    #     return self.get_model().objects.filter(is_launched=True)
